do
$$
-- declare
begin
  delete from sm_sc.tb_nn_node where work_no = -000000027;
  delete from sm_sc.tb_nn_path where work_no = -000000027;
  commit;
  
  -- 构造节点
  insert into sm_sc.tb_nn_node
  (
    work_no
  , node_no
  , node_type
  , node_fn_type       
  , node_fn_asso_value
  -- , node_desc
  )
  -- rand_pick input
  select 
    -000000027                                               as work_no                
  , -100000000                                               as node_no
  , 'input_01'                                               as node_type                   
  , '00_buff_slice_rand_pick'                                as node_fn_type
  , null :: decimal[]                                        as node_fn_asso_value
  -- , ''                                                       as node_desc

  -- 第一大层 DNN
  union all
  select 
    -000000027                                               as work_no                
  , -201010002                                               as node_no
  , 'weight'                                                 as node_type  
  , '00_const'                                               as node_fn_type         
  , array[1, 314, 1024] :: decimal[]                             as node_fn_asso_value  
  -- , ''                                                       as node_desc
  union all
  select 
    -000000027                                               as work_no                
  , -201010003                                               as node_no
  , 'weight'                                                 as node_type  
  , '00_const'                                               as node_fn_type         
  , array[1, 1024] :: decimal[]                                 as node_fn_asso_value  
  -- , ''                                                       as node_desc
  union all
  select 
    -000000027                                               as work_no                
  , -201020001                                               as node_no
  , null                                                     as node_type                   
  , '05_tunnel_conv'                                             as node_fn_type
  , array[2] :: decimal[]                            as node_fn_asso_value  
  -- , ''                                                       as node_desc
  -- -- union all                                                  
  -- -- -- 重分布
  -- -- select                                                     
  -- --   -000000027                                               as work_no                
  -- -- , -201030001                                               as node_no
  -- -- , null                                                     as node_type                   
  -- -- , '03_zscore'                                              as node_fn_type
  -- -- , array[1, 1024]                                        as node_fn_asso_value
  -- -- -- , ''                                                       as node_desc
  union all                                                  
  -- 激活
  select                                                     
    -000000027                                               as work_no                
  , -201040001                                               as node_no
  , null                                                     as node_type                   
  , '03_absqrt'                                              as node_fn_type
  , array[0.5, 0.0]                                          as node_fn_asso_value
  -- , ''                                                       as node_desc

  -- 第二大层 DNN
  union all
  select 
    -000000027                                               as work_no                
  , -202010002                                               as node_no
  , 'weight'                                                 as node_type  
  , '00_const'                                               as node_fn_type         
  , array[1, 1024, 512] :: decimal[]                            as node_fn_asso_value  
  -- , ''                                                       as node_desc
  union all
  select 
    -000000027                                               as work_no                
  , -202010003                                               as node_no
  , 'weight'                                                 as node_type  
  , '00_const'                                               as node_fn_type         
  , array[1, 512] :: decimal[]                            as node_fn_asso_value  
  -- , ''                                                       as node_desc
  union all
  select 
    -000000027                                               as work_no                
  , -202020001                                               as node_no
  , null                                                     as node_type                   
  , '05_tunnel_conv'                                             as node_fn_type
  , array[2] :: decimal[]                            as node_fn_asso_value  
  -- , ''                                                       as node_desc
  -- -- union all                                                  
  -- -- -- 重分布
  -- -- select                                                     
  -- --   -000000027                                               as work_no                
  -- -- , -202030001                                               as node_no
  -- -- , null                                                     as node_type                   
  -- -- , '03_zscore'                                              as node_fn_type
  -- -- , array[1, 512]                                        as node_fn_asso_value
  -- -- -- , ''                                                       as node_desc
  union all                                                  
  -- 激活
  select                                                     
    -000000027                                               as work_no                
  , -202040001                                               as node_no
  , null                                                     as node_type                   
  , '03_absqrt'                                              as node_fn_type
  , array[0.5, 0.0]                                          as node_fn_asso_value
  -- , ''                                                       as node_desc

  -- 第三大层 DNN
  union all
  select 
    -000000027                                               as work_no                
  , -203010002                                               as node_no
  , 'weight'                                                 as node_type  
  , '00_const'                                               as node_fn_type         
  , array[1, 512, 256] :: decimal[]                            as node_fn_asso_value  
  -- , ''                                                       as node_desc
  union all
  select 
    -000000027                                               as work_no                
  , -203010003                                               as node_no
  , 'weight'                                                 as node_type  
  , '00_const'                                               as node_fn_type         
  , array[1, 256] :: decimal[]                            as node_fn_asso_value  
  -- , ''                                                       as node_desc
  union all
  select 
    -000000027                                               as work_no                
  , -203020001                                               as node_no
  , null                                                     as node_type                   
  , '05_tunnel_conv'                                             as node_fn_type
  , array[2] :: decimal[]                            as node_fn_asso_value  
  -- , ''                                                       as node_desc
  -- -- union all                                                  
  -- -- -- 重分布
  -- -- select                                                     
  -- --   -000000027                                               as work_no                
  -- -- , -203030001                                               as node_no
  -- -- , null                                                     as node_type                   
  -- -- , '03_zscore'                                              as node_fn_type
  -- -- , array[1, 256]                                        as node_fn_asso_value
  -- -- -- , ''                                                       as node_desc
  union all                                                  
  -- 激活
  select                                                     
    -000000027                                               as work_no                
  , -203040001                                               as node_no
  , null                                                     as node_type                   
  , '03_absqrt'                                              as node_fn_type
  , array[0.5, 0.0]                                          as node_fn_asso_value
  -- , ''                                                       as node_desc

  -- 第四大层 DNN
  union all
  select 
    -000000027                                               as work_no                
  , -204010002                                               as node_no
  , 'weight'                                                 as node_type  
  , '00_const'                                               as node_fn_type         
  , array[1, 256, 64] :: decimal[]                            as node_fn_asso_value  
  -- , ''                                                       as node_desc
  union all
  select 
    -000000027                                               as work_no                
  , -204010003                                               as node_no
  , 'weight'                                                 as node_type  
  , '00_const'                                               as node_fn_type         
  , array[1, 64] :: decimal[]                            as node_fn_asso_value  
  -- , ''                                                       as node_desc
  union all
  select 
    -000000027                                               as work_no                
  , -204020001                                               as node_no
  , null                                                     as node_type                   
  , '05_tunnel_conv'                                             as node_fn_type
  , array[2] :: decimal[]                            as node_fn_asso_value  
  -- , ''                                                       as node_desc
  -- -- union all                                                  
  -- -- -- 重分布
  -- -- select                                                     
  -- --   -000000027                                               as work_no                
  -- -- , -204030001                                               as node_no
  -- -- , null                                                     as node_type                   
  -- -- , '03_zscore'                                              as node_fn_type
  -- -- , array[1, 64]                                        as node_fn_asso_value
  -- -- -- , ''                                                       as node_desc
  union all                                                  
  -- 激活
  select                                                     
    -000000027                                               as work_no                
  , -204040001                                               as node_no
  , null                                                     as node_type                   
  , '03_absqrt'                                              as node_fn_type
  , array[0.5, 0.0]                                          as node_fn_asso_value
  -- , ''                                                       as node_desc
  
  -- 最后大层
  union all
  select 
    -000000027                                               as work_no                
  , -901010002                                               as node_no
  , 'weight'                                                 as node_type  
  , '00_const'                                               as node_fn_type         
  , array[1, 64, 1] :: decimal[]                                as node_fn_asso_value  
  -- , ''                                                       as node_desc
  union all
  select 
    -000000027                                               as work_no                
  , -901010003                                               as node_no
  , 'weight'                                                 as node_type  
  , '00_const'                                               as node_fn_type         
  , array[1, 1] :: decimal[]                                as node_fn_asso_value  
  -- , ''                                                       as node_desc
  union all
  select 
    -000000027                                               as work_no                
  , -999999999                                               as node_no
  , 'output_01'                                                     as node_type  
  , '05_tunnel_conv'                                               as node_fn_type         
  , array[2] :: decimal[]                                as node_fn_asso_value  
  -- , ''                                                       as node_desc
  -- union all                                                  
  -- select                                                     
  --   -000000027                                               as work_no              
  -- , -999999999                                               as node_no
  -- , 'output_01'                                              as node_type        
  -- , '03_softmax_ex'                                          as node_fn_type           
  -- , array[1, 2] :: decimal[]                                        as node_fn_asso_value
  -- -- , ''                                                       as node_desc
  ;
  commit;
  
  -- 构造路径
  insert into sm_sc.tb_nn_path
  (
    work_no              ,
    fore_node_no         ,
    path_ord_no          ,
    back_node_no
  )

  -- 第一大层
  select                                                                                       
    -000000027                                                                                 as work_no             
  , -201020001                                                                                 as fore_node_no
  , 1                                                                                          as path_ord_no         
  , -100000000                                                                                 as back_node_no   
      
  union all                                                                                    
  select                                                                                       
    -000000027                                                                                 as work_no             
  , -201020001                                                                                 as fore_node_no
  , 2                                                                                          as path_ord_no         
  , -201010002                                                                                 as back_node_no    
      
  union all                                                                                    
  select                                                                                       
    -000000027                                                                                 as work_no             
  , -201020001                                                                                 as fore_node_no
  , 3                                                                                          as path_ord_no         
  , -201010003                                                                                 as back_node_no  
      
  union all                                                                                    
  select                                                                                       
    -000000027                                                                                 as work_no             
  , -201040001                                                                                 as fore_node_no
  , 1                                                                                          as path_ord_no         
  , -201020001                                                                                 as back_node_no    
      
  -- -- union all                                                                                    
  -- -- select                                                                                       
  -- --   -000000027                                                                                 as work_no             
  -- -- , -201040001                                                                                 as fore_node_no
  -- -- , 1                                                                                          as path_ord_no         
  -- -- , -201030001                                                                                 as back_node_no    

  union all
  -- 第二大层
  select                                                                                       
    -000000027                                                                                 as work_no             
  , -202020001                                                                                 as fore_node_no
  , 1                                                                                          as path_ord_no         
  , -201040001                                                                                 as back_node_no   
      
  union all                                                                                    
  select                                                                                       
    -000000027                                                                                 as work_no             
  , -202020001                                                                                 as fore_node_no
  , 2                                                                                          as path_ord_no         
  , -202010002                                                                                 as back_node_no   
      
  union all                                                                                    
  select                                                                                       
    -000000027                                                                                 as work_no             
  , -202020001                                                                                 as fore_node_no
  , 3                                                                                          as path_ord_no         
  , -202010003                                                                                 as back_node_no    
      
  union all                                                                                    
  select                                                                                       
    -000000027                                                                                 as work_no             
  , -202040001                                                                                 as fore_node_no
  , 1                                                                                          as path_ord_no         
  , -202020001                                                                                 as back_node_no    
      
  -- -- union all                                                                                    
  -- -- select                                                                                       
  -- --   -000000027                                                                                 as work_no             
  -- -- , -202040001                                                                                 as fore_node_no
  -- -- , 1                                                                                          as path_ord_no         
  -- -- , -202030001                                                                                 as back_node_no  

  union all
  -- 第三大层
  select                                                                                       
    -000000027                                                                                 as work_no             
  , -203020001                                                                                 as fore_node_no
  , 1                                                                                          as path_ord_no         
  , -202040001                                                                                 as back_node_no   
      
  union all                                                                                    
  select                                                                                       
    -000000027                                                                                 as work_no             
  , -203020001                                                                                 as fore_node_no
  , 2                                                                                          as path_ord_no         
  , -203010002                                                                                 as back_node_no   
      
  union all                                                                                    
  select                                                                                       
    -000000027                                                                                 as work_no             
  , -203020001                                                                                 as fore_node_no
  , 3                                                                                          as path_ord_no         
  , -203010003                                                                                 as back_node_no    
      
  union all                                                                                    
  select                                                                                       
    -000000027                                                                                 as work_no             
  , -203040001                                                                                 as fore_node_no
  , 1                                                                                          as path_ord_no         
  , -203020001                                                                                 as back_node_no   
      
  -- -- union all                                                                                    
  -- -- select                                                                                       
  -- --   -000000027                                                                                 as work_no             
  -- -- , -203040001                                                                                 as fore_node_no
  -- -- , 1                                                                                          as path_ord_no         
  -- -- , -203030001                                                                                 as back_node_no   

  union all
  -- 第四大层
  select                                                                                       
    -000000027                                                                                 as work_no             
  , -204020001                                                                                 as fore_node_no
  , 1                                                                                          as path_ord_no         
  , -203040001                                                                                 as back_node_no   
      
  union all                                                                                    
  select                                                                                       
    -000000027                                                                                 as work_no             
  , -204020001                                                                                 as fore_node_no
  , 2                                                                                          as path_ord_no         
  , -204010002                                                                                 as back_node_no   
      
  union all                                                                                    
  select                                                                                       
    -000000027                                                                                 as work_no             
  , -204020001                                                                                 as fore_node_no
  , 3                                                                                          as path_ord_no         
  , -204010003                                                                                 as back_node_no    
      
  union all                                                                                    
  select                                                                                       
    -000000027                                                                                 as work_no             
  , -204040001                                                                                 as fore_node_no
  , 1                                                                                          as path_ord_no         
  , -204020001                                                                                 as back_node_no   
      
  -- -- union all                                                                                    
  -- -- select                                                                                       
  -- --   -000000027                                                                                 as work_no             
  -- -- , -204040001                                                                                 as fore_node_no
  -- -- , 1                                                                                          as path_ord_no         
  -- -- , -204030001                                                                                 as back_node_no   
  
  union all
  -- 最后大层
  select                                                                                       
    -000000027                                                                                 as work_no             
  , -999999999                                                                                 as fore_node_no
  , 1                                                                                          as path_ord_no         
  , -204040001                                                                                 as back_node_no   
      
  union all                                                                                    
  select                                                                                       
    -000000027                                                                                 as work_no             
  , -999999999                                                                                 as fore_node_no
  , 2                                                                                          as path_ord_no         
  , -901010002                                                                                 as back_node_no      
      
  union all                                                                                    
  select                                                                                       
    -000000027                                                                                 as work_no             
  , -999999999                                                                                 as fore_node_no
  , 3                                                                                          as path_ord_no         
  , -901010003                                                                                 as back_node_no    
      
  -- union all                                                                                    
  -- select                                                                                       
  --   -000000027                                                                                 as work_no             
  -- , -999999999                                                                                 as fore_node_no
  -- , 1                                                                                          as path_ord_no         
  -- , -902010001                                                                                 as back_node_no    
  ;
  commit;

end
$$
language plpgsql;
